# 函数基本语法

def say_hi():
    print("hello, I am func")


def add(a, b):
    """
    解释是自动补全的
    :param a:第一个加数
    :param b:第二个加数
    :return:两个加数的和
    """
    s = a + b
    return s


say_hi()
print(add(12, 3))

# global 关键字将局部变量声明为全局变量
num = 100


def pt():
    # num = 200  # 本质是一个新的变量
    print(num)


def pt2():
    global num
    num = 200
    print(num)


pt()
print(num)
pt2()
print(num)

# 函数案例
money = 5000000
name = "李四"


def find():
    print(f"当前余额是{money}元")


def update():
    up = int(input("请输入存储金额:"))
    global money
    money += up
    print("存储成功,", end='')
    find()


def get():
    down = int(input("请输入取款金额:"))
    global money
    if down <= money:
        money -= down
        print("取款成功,", end='')
        find()
    else:
        print(f"当前余额为:{money},小于取款金额,取款失败")


def menu():
    print("1、查询余额")
    print("2、存款")
    print("3、取款")


def main():
    menu()
    choice = int(input("请输入你的选择"))
    while 1 <= choice <= 3:
        if choice == 1:
            find()
        elif choice == 2:
            update()
        elif choice == 3:
            get()
        choice = int(input("请输入你的选择"))


main()
